package com.ydd.mqserver.mq.producer;

import com.ydd.mqserver.base.ExchangeName;
import com.ydd.mqserver.base.RoutingKeyName;
import com.ydd.mqserver.vo.NotifyMsgSendVO;
import lombok.extern.slf4j.Slf4j;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Slf4j
@Component
public class RabbitmqProducer{

    @Autowired
    private RabbitTemplate rabbitTemplate;



    public void send(NotifyMsgSendVO notifyMsgSendVO) {
        log.debug("生产消息【{}】", notifyMsgSendVO);
        CorrelationData correlationData = new CorrelationData(notifyMsgSendVO.getPriKey());
        this.rabbitTemplate.convertAndSend(
                ExchangeName.NOTIFY_MSG,
                RoutingKeyName.NOTIFY_MSG_KEY,
                notifyMsgSendVO,
                correlationData
        );
    }


}